package com.bjypc.youth.web.chart;

import java.text.NumberFormat;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.StandardPieSectionLabelGenerator;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.util.Rotation;

import com.opensymphony.xwork2.ActionSupport;

public class YouthLeagueOrgInfo2007Action extends ActionSupport {

	/**
	 * serialVersionUID
	 */
	private static final long serialVersionUID = 7368111933501320757L;
	// JChartResult->ActionInvocation.getStack().findValue("chart")
	private JFreeChart chart;

	public YouthLeagueOrgInfo2007Action() {
		super();
	}

	@Override
	public String execute() throws Exception {
		DefaultPieDataset data = new DefaultPieDataset();
		data.setValue("企业系统", new Double(117));
		data.setValue("青农系统", new Double(16));
		data.setValue("社区系统", new Double(19));
		data.setValue("大学系统", new Double(64));
		data.setValue("奥组委团委", new Double(1.0));
		
		// JFreeChart
		chart = ChartFactory.createPieChart3D("2007年度北京市共青团组织情况", data, true, true,
				false);
		PiePlot3D pieplot3d = (PiePlot3D)chart.getPlot();
		pieplot3d.setStartAngle(290D);
		pieplot3d.setDirection(Rotation.CLOCKWISE);
		pieplot3d.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()));
		pieplot3d.setLegendLabelToolTipGenerator(new StandardPieSectionLabelGenerator("Tooltip for legend item {0}"));
		pieplot3d.setNoDataMessage("No data to display");
		return SUCCESS;
	}

	public JFreeChart getChart() {
		return chart;
	}

	public void setChart(JFreeChart chart) {
		this.chart = chart;
	}
}
